package com.bingxu.flink.chapter02.transformation;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

import java.util.Arrays;
import java.util.List;


/**
 * @author :BingXu
 * @description :TODO
 * @date :2021/8/9 11:34
 * @modifier :
 */

public class Trans_Filter {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//        DataStreamSource<String> source = env.socketTextStream("localhost", 8989);
        DataStreamSource<List<Integer>> source = env.fromElements(Arrays.asList(1, 2, 43, 23, 545, 678, 78, 90));

        SingleOutputStreamOperator<List<Integer>> filterDS = source.filter(new FilterFunction<List<Integer>>() {
            @Override
            public boolean filter(List<Integer> integers) throws Exception {
                return integers.size() / 2 != 0;
            }
        });

        filterDS.print();

        env.execute();

    }
}
